
<script type="text/template" id="readTemplate">
        <tr id="${return_id}">
                <td>${return_id}</td>
                <td>${return_date}</td>
				<td>${user_name}</td>
				<td>${outlet_name}</td>
				
                <td><a class="updateBtn" href="${updateLink}">Detail</a> | <a class="deleteBtn" href="${deleteLink}">PDF</a></td>
                <!--<td width="110px"><a class="updateBtn" href="${updateLink}">Detail</a></td>
				<td><a class="updateBtn" href="${updateLink}">Detail</a></td>-->
                
        </tr>
</script>

<script type="text/javascript">
var readUrl   = 'index.php/returns/readSuccess';
     updateUrl = 'index.php/returns/returnSuccessDetail',
     delUrl    = 'index.php/returns/printAuthorized',
    // delHref,
    // updateHref,
    // updateId;


$( function() {
    
    $( '#tabs' ).tabs({
        fx: { height: 'toggle', opacity: 'toggle' }
    });
    
    readUsers();
    
    $( '#msgDialog' ).dialog({
        autoOpen: false,
        
        buttons: {
            'Ok': function() {
                $( this ).dialog( 'close' );
            }
        }
    });
    
    
    
    /*$( '#records' ).delegate( 'a.updateBtn', 'click', function() {
        updateHref = $( this ).attr( 'href' );
        updateId = $( this ).parents( 'tr' ).attr( "id" );
        
        $( '#ajaxLoadAni' ).fadeIn( 'slow' );
        
        $.ajax({
            url: 'index.php/returns/returndetail/' + updateId
            dataType: 'json',
            
            success: function( response ) {
                $( '#return_id' ).val( response.return_id );
                $( '#return_date' ).val( response.return_date );
                $( '#user_name' ).val( response.user_name );
                $( '#outlet_name' ).val( response.outlet_name );
                //$( '#ordering' ).val( response.ordering );
                //$( '#published' ).val( response.published );
                
                $( '#ajaxLoadAni' ).fadeOut( 'slow' );
                
                //--- assign id to hidden field ---
                $( '#userId' ).val( updateId );
                
                $( '#updateDialog' ).dialog( 'open' );
            }
        });
        
        return false;
    });  *///end update delegate
    
    
    
}); //end document ready


function readUsers() {
    //display ajax loader animation
    $( '#ajaxLoadAni' ).fadeIn( 'slow' );
    
    $.ajax({
        url: readUrl,
        dataType: 'json',
        success: function( response ) {
            var j=1;
			//alert(response.length);
            for( var i in response ) {
                response[ i ].updateLink = updateUrl + '/' + response[ i ].return_id;
                response[ i ].deleteLink = delUrl + '/' + response[ i ].return_id;
                //response[ i ].nomor = j;
				//alert("tes");
                //j++;
            }
            
			
            //clear old rows
            $( '#records > tbody' ).html( '' );
            
            //append new rows
            $( '#readTemplate' ).render( response ).appendTo( "#records > tbody" );
            
            //apply dataTable to #records table and save its object in dataTable variable
            if( typeof dataTable == 'undefined' )
                dataTable = $( '#records' ).dataTable({"bJQueryUI": true});
            
            //hide ajax loader animation here...
            $( '#ajaxLoadAni' ).fadeOut( 'slow' );
        }
    });
} // end readUsers
</script>